package com.l.brownapp;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.Toast;

import com.l.brownapp.utils.Log;
import com.l.brownapp.utils.StaticMethod;
import com.makeramen.segmented.SegmentedRadioGroup;

public class OptionFragment extends Fragment implements OnCheckedChangeListener{
	private static final String TAG = "OptionFragment";
//	private String defaultHello = "default value";
	
	SegmentedRadioGroup segmentText;
	SegmentedRadioGroup segmentImg;
//	Toast mToast;

	static OptionFragment newInstance(String s) {
		OptionFragment newFragment = new OptionFragment();
		Bundle bundle = new Bundle();
		bundle.putString("hello", s);
		newFragment.setArguments(bundle);
		return newFragment;

	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Log.d(TAG, "OptionFragment-----onCreate");
//		Bundle args = getArguments();
//		hello = args != null ? args.getString("hello") : defaultHello;
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
//		Log.d(TAG, "TestFragment-----onCreateView");
		View view = inflater.inflate(R.layout.fragment_option, container, false);
//		TextView viewhello = (TextView) view.findViewById(R.id.tv_hello);
//		viewhello.setText(hello);
		
	    segmentText = (SegmentedRadioGroup) view.findViewById(R.id.segment_text);
        segmentText.setOnCheckedChangeListener(this);
        segmentImg = (SegmentedRadioGroup) view.findViewById(R.id.segment_img);
        segmentImg.setOnCheckedChangeListener(this);

		return view;

	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState)
	{
		// TODO Auto-generated method stub
		super.onActivityCreated(savedInstanceState);
		
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
//		Log.d(TAG, "TestFragment-----onDestroy");
	}

	/* (non-Javadoc)
	 * @see android.widget.RadioGroup.OnCheckedChangeListener#onCheckedChanged(android.widget.RadioGroup, int)
	 */
	@Override
	public void onCheckedChanged(RadioGroup group, int checkedId)
	{
//      mToast = Toast.makeText(getActivity(), "", Toast.LENGTH_SHORT);

		String str="";
		if (group == segmentText) {
			if (checkedId == R.id.button_one) {
//				mToast.setText("One");
				str="One";
	//			mToast.show();
			} else if (checkedId == R.id.button_two) {
//				mToast.setText("Two");
				str="Two";
	//			mToast.show();
			} else if (checkedId == R.id.button_three) {
//				mToast.setText("Three");
				str="Three";
	//			mToast.show();
			}
		} else if (group == segmentImg) {
			if (checkedId == R.id.button_add) {
//				mToast.setText("Add");
				str="Add";
	//			mToast.show();
			} else if (checkedId == R.id.button_call) {
//				mToast.setText("Call");
				str="Call";
	//			mToast.show();
			} else if (checkedId == R.id.button_camera) {
//				mToast.setText("Camera");
				str="Camera";
	//			mToast.show();
			}
		}
			StaticMethod.showToast(getActivity(), str, Toast.LENGTH_SHORT);
	}

}
